package com.fresh.mapper;

import com.fresh.entity.RawIn;
import com.fresh.entity.RawInQO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface YuanLiaoMapper {

    List<RawIn> findPageInfoByCondition(RawInQO rawInQO);

    @Insert("insert into raw_in values(#{riId},#{cgNo},#{cgGname},#{cgNum},#{cgUname},#{riName},#{riSname},#{riNum},#{riPrice},#{riStorage},#{riIn},#{riEnd},1)")
    void insert(RawIn rawIn);

    void update(RawIn rawIn);

    @Update("update raw_in set ri_status = 3,ri_end = #{data} where cg_no = #{cgNo}")
    void updateStatus3ByCgNo(@Param("cgNo") String cgNo, @Param("data") String data);

    @Update("update raw_in set ri_status = 4,ri_end = #{data} where cg_no = #{cgNo}")
    void updateStatus4ByCgNo(@Param("cgNo") String cgNo, @Param("data") String data);

    @Select("select ri_num from raw_in where cg_no = #{cgNo}")
    Integer getRiNum(String cgNo);

    @Update("update raw_in set ri_num = ri_num - #{roNum} where cg_no = #{cgNo}")
    void updateRiNum(@Param("cgNo") String cgNo, @Param("roNum") Integer roNum);

}
